home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Source / gtlayout-source.lha / LTP_DrawIncrementer.c < prev    next >
C/C++ Source or Header  |  1996-03-18  |  1KB  |  59 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. VOID
  15. LTP_DrawIncrementer(struct RastPort *rp,struct DrawInfo *drawInfo,BOOL leftDirection,LONG left,LONG top,LONG width,LONG height)
  16. {
  17.     LONG arrowWidth,arrowHeight;
  18.     LONG mid,a,b,inc,i;
  19.  
  20.     arrowWidth    = (width < height ? width : height) - 4;
  21.     arrowHeight    = (drawInfo->dri_Resolution.X * arrowWidth) / drawInfo->dri_Resolution.Y;
  22.  
  23.     if(arrowHeight < 5)
  24.         arrowHeight = 5;
  25.  
  26.     if(arrowHeight > height)
  27.         arrowHeight = height;
  28.  
  29.     arrowHeight = ((arrowHeight - 1) & ~1) + 1;
  30.  
  31.     left    += (width - arrowWidth) / 2;
  32.     top        += (height - arrowHeight) / 2;
  33.  
  34.     mid = top + arrowHeight / 2;
  35.  
  36.     if(leftDirection)
  37.     {
  38.         a    = left + arrowWidth - 1;
  39.         b    = left;
  40.         inc    = 1;
  41.     }
  42.     else
  43.     {
  44.         a    = left;
  45.         b    = left + arrowWidth - 1;
  46.         inc    = -1;
  47.     }
  48.  
  49.     for(i = 0 ; i < 4 ; i++)
  50.     {
  51.             // Note: two calls to ensure symmetry
  52.  
  53.         LTP_DrawLine(rp,a,top,b,mid);
  54.         LTP_DrawLine(rp,a,top + arrowHeight - 1,b,mid);
  55.  
  56.         b += inc;
  57.     }
  58. }
  59.